package com.example.personnel_oa.service.impl;
//service 接口 服务层
import com.example.comment_oa.pojos.Contract;
import com.example.comment_oa.pojos.SysEmployee;
import com.example.personnel_oa.mapper.ContractMapper;
import com.example.personnel_oa.mapper.DimissionMapper;
import com.example.personnel_oa.mapper.SysEmployeeMapper;
import com.example.personnel_oa.service.ContractService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
* @author HUAWEI
* @description 针对表【contract】的数据库操作Service实现
* @createDate 2022-10-20 17:03:17
*/
@Service
public class ContractServiceImpl implements ContractService {
    @Autowired//Spring对组件自动装配（Spring通过依赖注入通过IOC容器中各种组件的依赖关系赋值）的方法
    ContractMapper contractMapper;
    @Autowired
    SysEmployeeMapper employeeMapper;
    @Autowired
    DimissionMapper dimissionMapper;


    //查询出全部合同
    @Override
    public List<Contract> Methods_con(){
        List<Contract> Contracts = contractMapper.Methods_con();
        return  Contracts;
    }

    //员工入职后添加到合同表中，未签署试用合同
    @Override
    public int addContract(Contract contract) {
        int i = contractMapper.addContract(contract);
        return i;
    }

    //根据id查询合同数据
    @Override
    public Contract conId(int conId) {
        Contract contract = contractMapper.conId(conId);
        return contract;
    }

    //签试用合同
    @Override
    public int shiyong(Contract contract) {
        int shiyong = contractMapper.shiyong(contract);
        return shiyong;
    }

    //新增正式合同
    @Override
    public int zhengshi(Contract contract) {
        int zhengshi = contractMapper.zhengshi(contract);
        int i = employeeMapper.setEmpState(contract.getEmpId());
        return zhengshi;
    }

    //新增解除合同
    @Override
    public int jiechu(Contract contract) {
        int jiechu = contractMapper.jiechu(contract);
        int i = employeeMapper.setEmpState2(contract.getEmpId());
        return jiechu;
    }

}




